@extends('backstage.layout.master')
@section('title', '取消订单')

@section('script')
    <script type="text/javascript">
        function cancelOrder(th){
            var reason = $("#reason").val();
            if(reason == undefined || reason == ""){
                swal('请填写取消原因','','warning');
                return ;
            }
            swal({
                title:"确认取消吗？",
                text:"",
                type:"warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                cancelButtonText:"取消",
                closeOnConfirm: false,
                closeOnCancel: true
            },function(){
                $reason = $("#reason").val();
                $.ajax({
                    url:"/backstage/order/order-cancel",
                    type:"post",
                    data:{"order_id":th, "reason":reason},
                    datatype:'json',
                    success:function(re){
                        if(re.state=="M00000"){
                                swal(re.message,'','success');
                                window.location.href='/backstage/order/order-detail?order_id=' + th;
                                return;
                        }else if(re.state=="M00003"){
                            window.location.href=re.result.url;
                            return ;
                        }
                        swal(re.message,'','warning');
                    },
                    error:function(){
                        swal('系统繁忙','请稍后重试','warning');return;
                    }
                });
            });
        }
    </script>
@stop

@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">主页</a>
            </li>

            <li class="active">
                <a href="/backstage/order/showaddexpress">订单发货</a>
            </li>
        </ul><!-- .breadcrumb -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        订单取消
                    </h1>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="page-content">
                            <div class="page-header preview-header">
                                <h1>
                                    订单取消
                                </h1>
                            </div><!-- /.page-header -->

                            <div class="table-responsive">
                                <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                                    <tr>
                                        <td> 订单编号 </td>
                                        <td colspan="2">
                                            {{isset($result->order_id) ? $result->order_id : ''}}
                                        </td>
                                    </tr>

                                    <tr>
                                        <td> 订单金额 </td>
                                        <td>
                                            {{isset($result->total_fee) ? $result->total_fee : ''}}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td> 取消原因(必填) </td>
                                        <td colspan="2">
                                            <textarea id="reason" style="width:200px;height:100px;"></textarea>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div class="clearfix form-actions"  >
                                <div class="col-md-offset-5 col-md-9">
                                    <button class="btn btn-info" onclick="cancelOrder({{isset($result->order_id) ? $result->order_id : ''}});">
                                        <i class="icon-ok bigger-110"></i>
                                        确认取消
                                    </button>
                                </div>
                            </div>


                        </div><!-- /page-content -->
                    </div><!-- col -->
                </div><!-- row -->
            </div><!-- col -->
        </div><!-- row -->
    </div><!-- /.page-content -->

@stop
@section('script')
@stop
